package DBHelper;

import exceptions.ObjectNotFoundException;
import java.math.BigInteger;
import java.sql.SQLException;

public class MutableDBObject extends DBObject {

    public MutableDBObject() {
        
    }
    public MutableDBObject(BigInteger id) throws SQLException, ObjectNotFoundException {
        super(id);
    }
    @Override
    public void setName(String name) throws SQLException {
        String query = "update objects set name = '"+name+"' where object_id = "+this.getId();
        DBHelper.updateQuery(query);
    }
    @Override
    public void setParentId(BigInteger parentId) throws SQLException {
        String query = "update objects set parent_id = "+parentId+" where object_id = "+this.getId();
        DBHelper.updateQuery(query);
    }
    @Override
    public void setObjectTypeId(BigInteger objectTypeId) throws SQLException {
        String query = "update objects set object_type_id = "+objectTypeId+" where object_id = "+this.getId();
        DBHelper.updateQuery(query);
    }
    @Override
    public void setDescription(String descr) throws SQLException {
        String query = "update objects set description = '"+descr+"' where object_id = "+this.getId();
        DBHelper.updateQuery(query);
    }
}
